package com.workstudy.wstudy.controller;

import com.workstudy.common.core.controller.BaseController;
import com.workstudy.common.core.domain.entity.SysDept;
import com.workstudy.common.core.page.TableDataInfo;
import com.workstudy.wstudy.domain.WstPost;
import com.workstudy.wstudy.domain.WstStudent;
import com.workstudy.wstudy.service.IWstSummaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/wstudy/summary")
public class WstSummaryController extends BaseController {
    private String prefix = "wstudy/summary";

    @Autowired
    private IWstSummaryService summaryService;

    @GetMapping("/deptSummary")
    public String deptSummary()
    {
            return prefix + "/dept_summary";
    }

    @GetMapping("/postSummary")
    public String postSummary(WstPost wstPost,ModelMap map)
    {
        List<WstPost> list = summaryService.queryPostNum(wstPost);
        map.put("list",list);
        return prefix + "/post_summary";
    }

    @GetMapping("/studentSummary")
    public String student()
    {
        return prefix + "/student_summary";
    }

    /**
     * 所有部门岗位分析数据
     */
    @PostMapping("/queryDeptPost")
    @ResponseBody
    public TableDataInfo queryDeptPost(SysDept sysDept)
    {
        startPage();
        List<SysDept> list = summaryService.queryDeptPost(sysDept);
        return getDataTable(list);
    }
    /**
     * 本部门岗位分析数据
     */
    @PostMapping("/queryPostNum")
    @ResponseBody
    public TableDataInfo queryPostNum(WstPost wstPost)
    {
        startPage();
        List<WstPost> list = summaryService.queryPostNum(wstPost);
        return getDataTable(list);
    }

    /**
     * 学生排行榜
     */
    @PostMapping("/queryStudent")
    @ResponseBody
    public TableDataInfo queryStudent(WstStudent wstStudent)
    {
        startPage();
        List<WstStudent> list = summaryService.queryStudent(wstStudent);
        return getDataTable(list);
    }
}
